//
//  XHBankCardCell.m
//  elxc
//
//  Created by 冷山 on 16/3/29.
//  Copyright © 2016年 lexingsoft. All rights reserved.
//

#import "XHBankCardCell.h"

@interface XHBankCardCell()<UITextFieldDelegate>

@end

@implementation XHBankCardCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.la_thread1.constant = 0.5;
    self.la_thread2.constant = 0.5;
    self.la_thread3.constant = 0.5;
    [self.ui_jianTouBtn setImage:[UIImage imageNamed:@"geren_icon_xiajiantou"] forState:UIControlStateNormal];
    [self.ui_jianTouBtn setImage:[UIImage imageNamed:@"geren_icon_shangjiantou"] forState:UIControlStateSelected];
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if (textField == self.ui_cardNumber)
    {
        // 四位加一个空格
        if ([string isEqualToString:@""])
        {
            // 删除字符
            if ((textField.text.length - 2) % 5 == 0)
            {
                textField.text = [textField.text substringToIndex:textField.text.length - 1];
            }
            return YES;
        } else
        {
            if (textField.text.length % 5 == 0)
            {
                textField.text = [NSString stringWithFormat:@"%@ ", textField.text];
            }
        }
        return YES;
    }
    return YES;
}


- (IBAction)selectBank:(id)sender
{
    [_delegate selectBank];
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
